package com.pojo;

import lombok.Data;

/**
 * @author:周鹏
 * @date: 2020/11/3 14:06
 * @description:用于响应前端的消息代码类
 */
@Data
public class ResponseDto {
    private String msg;//返回前端信息
    private boolean res;//返回结果
    private Object data;//返回数据
    private Integer status;//状态
    private Integer errcode;

    public ResponseDto(String msg, boolean res, Object data, Integer status, Integer errcode) {
        this.msg = msg;
        this.res = res;
        this.data = data;
        this.status = status;
        this.errcode=errcode;
    }
    public static ResponseDto ok(String msg){
        ResponseDto dtoTest=new ResponseDto(msg,true,null,200,null);
        return dtoTest;
    }
    public static ResponseDto ok(String msg, Object data){
        ResponseDto dtoTest=new ResponseDto(msg,true,null,200,null);
        return dtoTest;
    }
    public static ResponseDto fail(String msg, Integer status, Integer errcode){

         return new ResponseDto(msg,false,null,status,errcode);
    }
}
